package com.example.blog.schedulerJob;

import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;


@DisallowConcurrentExecution //并发执行，要使用数据库锁来进行管理  防止数据被重复处理
public class TestJob implements Job {
    @Resource
    Scheduler scheduler;
    @Override
    public void execute(JobExecutionContext job) throws JobExecutionException {
        SimpleDateFormat format = new SimpleDateFormat();
        System.out.println(job.getJobDetail().getJobDataMap().get("name"));
        System.out.println(job.getJobDetail().getJobDataMap().get("id"));
        System.out.println("定时任务执行"+format.format(new Date()));
    }
}
